//
//  SingleLineInfoViewController.m
//  RainbowFM
//
//  Created by jv on 14-12-7.
//  Copyright (c) 2014年 RB. All rights reserved.
//

#import "SingleLineInfoViewController.h"
#import "UserModel.h"

@interface SingleLineInfoViewController ()

@end

@implementation SingleLineInfoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    _textField.placeholder = _placeHolderString;
    
    
    UIBarButtonItem *submitButton = [[UIBarButtonItem alloc] initWithTitle:@"确定"
                                                                     style:UIBarButtonItemStyleBordered
                                                                    target:self
                                                                    action:@selector(submitAction)];
    submitButton.tintColor = [UIColor whiteColor];
    
    self.navigationItem.rightBarButtonItem = submitButton;
    
}

#pragma mark - parent method

- (void)navBackAction
{
    if ([_delegate respondsToSelector:@selector(didFillInfoDoneWithCtrl:info:)]) {
        [_delegate didFillInfoDoneWithCtrl:self info:_textField.text];
    }
    
    [super navBackAction];
}


-(void)submitAction{
    if (_singleType == 0) {
        [[UserModel sharedModel] editUserProfileNickName:_textField.text reuslt:^(BOOL success) {
            if (success) {
                [SVProgressHUD showSuccessWithStatus:@"更改资料成功"];
                //            [[UserModel sharedModel] fetchUserProfile:^(BOOL success) {
                [self.navigationController popViewControllerAnimated:YES];
                //            }];
            }
        }];
    }
    
    else if(_singleType == 1){
        [[UserModel sharedModel] editUserProfileSign:_textField.text result:^(BOOL success) {
            [SVProgressHUD showSuccessWithStatus:@"更改资料成功"];
            [self.navigationController popViewControllerAnimated:YES];
 
        }];
    }
    
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
